package com.ruimei.controller;

import com.ruimei.service.ExamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@Api(tags={"成绩查询"})
public class ExamController
{
  @Resource
  ExamService examService;
  
  @ApiOperation("W通过年级id查询考试信息")
  @GetMapping({"/exam/{gradeId}"})
  @ResponseBody
  public Map<String, Object> getExamByGradeId(@PathVariable String gradeId)
  {
    Map<String, Object> map = this.examService.getExamByGradeId(gradeId);
    return map;
  }
  
  @ApiOperation("W通过考试id,studentName,classId查询学生总成绩")
  @PostMapping({"/score"})
  @ResponseBody
  public Map<String, Object> getScore(String examId, String studentName, String classId)
  {
    Map<String, Object> map = this.examService.getScore(examId, studentName, classId);
    return map;
  }
  
  @ApiOperation("W通过考试id,studentName,classId,subjectId查询学生科目成绩")
  @PostMapping({"/subject/score"})
  @ResponseBody
  public Map<String, Object> getSubjectScore(String examId, String studentName, String classId, String subjectId)
  {
    Map<String, Object> map = this.examService.getSubjectScore(examId, studentName, classId, subjectId);
    return map;
  }
  
  @ApiOperation("W通过考试id查询考试科目")
  @GetMapping({"/examsub/{examId}"})
  @ResponseBody
  public Map<String, Object> getSubjectByExamId(@PathVariable String examId)
  {
    Map<String, Object> map = this.examService.getSubjectByExamId(examId);
    return map;
  }
  
  @ApiOperation(value="W考试分析", notes="judge传入up上升，down下降，trend趋势")
  @PostMapping({"/exam/analyze"})
  @ResponseBody
  public Map<String, Object> analyzeExam(String bExamId, String eExamId, String id, String gradeId, String judge)
  {
    Map<String, Object> map = this.examService.analyzeExam(bExamId, eExamId, id, gradeId, judge);
    return map;
  }
  
  @ApiOperation(value="W成绩分析", notes="通过studentId获取考试成绩")
  @PostMapping({"/student/score"})
  @ResponseBody
  public Map<String, Object> getScoreByStudentId(String studentId, String gradeId, String examId)
  {
    Map<String, Object> map = this.examService.getScoreByStudentId(studentId, gradeId, examId);
    
    return map;
  }
  
  @ApiOperation(value="按照月份查詢成績", notes="通過examId/studentName/classId")
  @PostMapping({"/parent/score"})
  @ResponseBody
  public Map<String, Object> getScoreByparma(String examId, String studentName, String classId, String gradeId)
  {
    return this.examService.getParentScore(examId, studentName, classId, gradeId);
  }
  
  @ApiOperation(value="獲取總成績下的詳細成績", notes="通過studentId")
  @PostMapping({"/parent/getScore"})
  @ResponseBody
  public Map<String, Object> getScore(String studentId, String examId)
  {
    return this.examService.detailedResult(studentId, examId);
  }
}
